<?php

/**
 * taxrates actions.
 *
 * @package    sf_sandbox
 * @subpackage taxrates
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class taxratesActions extends sfActions
{
  public function executeIndex()
  {
    $this->tax_ratesList = TaxRatesPeer::doSelect(new Criteria());
  }

  public function executeCreate()
  {
    $this->form = new TaxRatesForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new TaxRatesForm(TaxRatesPeer::retrieveByPk($request->getParameter('tax_rates_id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new TaxRatesForm(TaxRatesPeer::retrieveByPk($request->getParameter('tax_rates_id')));

    $this->form->bind($request->getParameter('tax_rates'));
    if ($this->form->isValid())
    {
      $tax_rates = $this->form->save();

      $this->redirect('taxrates/edit?tax_rates_id='.$tax_rates->getTaxRatesId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($tax_rates = TaxRatesPeer::retrieveByPk($request->getParameter('tax_rates_id')));

    $tax_rates->delete();

    $this->redirect('taxrates/index');
  }
}
